/*
 * Copyright (c) 2017. 深圳掌控网络有限公司. All rights reserved.
 */

package com.yiqi.lottery.feature.mine.presenter;

import android.text.TextUtils;
import com.suozhang.framework.utils.T;
import com.suozhang.framework.utils.ValidatorUtil;
import com.yiqi.lottery.entity.bo.BalanceBo;
import com.yiqi.lottery.entity.bo.RechargeBo;
import com.yiqi.lottery.entity.bo.RegisterBo;
import com.yiqi.lottery.feature.mine.contract.BanlanceContract;
import com.yiqi.lottery.feature.mine.contract.BindContract;
import com.yiqi.lottery.feature.mine.contract.RechargeContract;
import com.yiqi.lottery.feature.mine.dependencies.banlance.DaggerBanlancePresenterComponent;
import com.yiqi.lottery.feature.mine.dependencies.bind.DaggerBindPresenterComponent;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

import javax.inject.Inject;

/**
 *      LIJUWEN
 * @email yiyayiyayaoljw@gmail.com
 * @date 2017/4/11 9:31
 */
public class BanlancePresenter implements BanlanceContract.Presenter {

    private BanlanceContract.View mView;

    @Inject

    BanlanceContract.Model mModel;


    public BanlancePresenter(BanlanceContract.View mView) {
        this.mView = mView;
        DaggerBanlancePresenterComponent.create().inject(this);
    }

    @Override
    public void start() {

    }

    @Override
    public void getMyBanlance() {
        mModel.getMyBanlance().compose(mView.bindToLife()).subscribe(new Observer<BalanceBo>() {
            @Override
            public void onSubscribe(Disposable d) {
                mView.showLoading(d);
            }

            @Override
            public void onNext(BalanceBo balanceBo) {
                mView.dismissLoading();
                mView.showMyBanlanceSuccess(balanceBo);
            }

            @Override
            public void onError(Throwable e) {
                mView.dismissLoading();
                mView.showMyBanlanceError(e.getMessage());
            }

            @Override
            public void onComplete() {
                mView.dismissLoading();
            }
        });
    }
}
